home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / pingpong.c < prev    next >
C/C++ Source or Header  |  2000-02-01  |  8KB  |  251 lines

  1. #include "driver.h"
  2. #include "vidhrdw/generic.h"
  3.  
  4.  
  5. void pingpong_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  6. void pingpong_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom);
  7.  
  8. static unsigned char *intenable;
  9.  
  10.  
  11. static int pingpong_interrupt(void)
  12. {
  13.     if (cpu_getiloops() == 0)
  14.     {
  15.         if (*intenable & 0x04) return interrupt();
  16.     }
  17.     else if (cpu_getiloops() % 2)
  18.     {
  19.         if (*intenable & 0x08) return nmi_interrupt();
  20.     }
  21.  
  22.     return ignore_interrupt();
  23. }
  24.  
  25.  
  26.  
  27. static struct MemoryReadAddress readmem[] =
  28. {
  29.     { 0x0000, 0x7FFF, MRA_ROM },
  30.     { 0x8000, 0x87FF, MRA_RAM },
  31.     { 0x9000, 0x97FF, MRA_RAM },
  32.     { 0xA800, 0xA800, input_port_0_r },
  33.     { 0xA880, 0xA880, input_port_1_r },
  34.     { 0xA900, 0xA900, input_port_2_r },
  35.     { 0xA980, 0xA980, input_port_3_r },
  36.     { -1 }    /* end of table */
  37. };
  38.  
  39. static struct MemoryWriteAddress writemem[] =
  40. {
  41.     { 0x0000, 0x7FFF, MWA_ROM },
  42.     { 0x8000, 0x83FF, colorram_w, &colorram },
  43.     { 0x8400, 0x87FF, videoram_w, &videoram, &videoram_size },
  44.     { 0x9000, 0x9002, MWA_RAM },
  45.     { 0x9003, 0x9052, MWA_RAM, &spriteram, &spriteram_size },
  46.     { 0x9053, 0x97FF, MWA_RAM },
  47.     { 0xA000, 0xA000, MWA_RAM, &intenable },    /* bit 2 = irq enable, bit 3 = nmi enable */
  48.                                                 /* bit 0/1 = coin counters */
  49.                                                 /* other bits unknown */
  50.     { 0xA200, 0xA200, MWA_NOP },        /* SN76496 data latch */
  51.     { 0xA400, 0xA400, SN76496_0_w },    /* trigger read */
  52.     { 0xA600, 0xA600, watchdog_reset_w },
  53.     { -1 }    /* end of table */
  54. };
  55.  
  56.  
  57.  
  58. INPUT_PORTS_START( pingpong )
  59.  
  60.     PORT_START    /* IN0 */
  61.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
  62.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
  63.     PORT_SERVICE( 0x04, IP_ACTIVE_LOW )
  64.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START2 )
  65.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START1 )
  66.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN3 )
  67.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN2 )
  68.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 )
  69.  
  70.     PORT_START    /* IN1 */
  71.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
  72.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_2WAY | IPF_PLAYER2 )
  73.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT| IPF_2WAY | IPF_PLAYER2 )
  74.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  75.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 )
  76.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_2WAY )
  77.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_2WAY )
  78.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 )
  79.  
  80.     PORT_START    /* DSW1 */
  81.     PORT_DIPNAME( 0x0F, 0x0F, DEF_STR( Coin_B ) )
  82.     PORT_DIPSETTING(    0x04, DEF_STR( 4C_1C ) )
  83.     PORT_DIPSETTING(    0x0A, DEF_STR( 3C_1C ) )
  84.     PORT_DIPSETTING(    0x01, DEF_STR( 2C_1C ) )
  85.     PORT_DIPSETTING(    0x02, DEF_STR( 3C_2C ) )
  86.     PORT_DIPSETTING(    0x08, DEF_STR( 4C_3C ) )
  87.     PORT_DIPSETTING(    0x0F, DEF_STR( 1C_1C ) )
  88.     PORT_DIPSETTING(    0x0C, DEF_STR( 3C_4C ) )
  89.     PORT_DIPSETTING(    0x0E, DEF_STR( 2C_3C ) )
  90.     PORT_DIPSETTING(    0x07, DEF_STR( 1C_2C ) )
  91.     PORT_DIPSETTING(    0x06, DEF_STR( 2C_5C ) )
  92.     PORT_DIPSETTING(    0x0B, DEF_STR( 1C_3C ) )
  93.     PORT_DIPSETTING(    0x03, DEF_STR( 1C_4C ) )
  94.     PORT_DIPSETTING(    0x0D, DEF_STR( 1C_5C ) )
  95.     PORT_DIPSETTING(    0x05, DEF_STR( 1C_6C ) )
  96.     PORT_DIPSETTING(    0x09, DEF_STR( 1C_7C ) )
  97.     PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ) )
  98.     PORT_DIPNAME( 0xF0, 0xF0, DEF_STR( Coin_A ) )
  99.     PORT_DIPSETTING(    0x40, DEF_STR( 4C_1C ) )
  100.     PORT_DIPSETTING(    0xA0, DEF_STR( 3C_1C ) )
  101.     PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) )
  102.     PORT_DIPSETTING(    0x20, DEF_STR( 3C_2C ) )
  103.     PORT_DIPSETTING(    0x80, DEF_STR( 4C_3C ) )
  104.     PORT_DIPSETTING(    0xF0, DEF_STR( 1C_1C ) )
  105.     PORT_DIPSETTING(    0xC0, DEF_STR( 3C_4C ) )
  106.     PORT_DIPSETTING(    0xE0, DEF_STR( 2C_3C ) )
  107.     PORT_DIPSETTING(    0x70, DEF_STR( 1C_2C ) )
  108.     PORT_DIPSETTING(    0x60, DEF_STR( 2C_5C ) )
  109.     PORT_DIPSETTING(    0xB0, DEF_STR( 1C_3C ) )
  110.     PORT_DIPSETTING(    0x30, DEF_STR( 1C_4C ) )
  111.     PORT_DIPSETTING(    0xD0, DEF_STR( 1C_5C ) )
  112.     PORT_DIPSETTING(    0x50, DEF_STR( 1C_6C ) )
  113.     PORT_DIPSETTING(    0x90, DEF_STR( 1C_7C ) )
  114.     PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ) )
  115.  
  116.     PORT_START    /* DSW2 */
  117.     PORT_DIPNAME( 0x01, 0x00, DEF_STR( Demo_Sounds ) )
  118.     PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
  119.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  120.     PORT_DIPNAME( 0x06, 0x06, DEF_STR( Difficulty ) )
  121.     PORT_DIPSETTING(    0x06, "Easy" )
  122.     PORT_DIPSETTING(    0x02, "Normal" )
  123.     PORT_DIPSETTING(    0x04, "Difficult" )
  124.     PORT_DIPSETTING(    0x00, "Very Difficult" )
  125.     PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unknown ) )
  126.     PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
  127.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  128.     PORT_DIPNAME( 0x10, 0x00, DEF_STR( Unknown ) )
  129.     PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
  130.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  131.     PORT_DIPNAME( 0x20, 0x00, DEF_STR( Unknown ) )
  132.     PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
  133.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  134.     PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )
  135.     PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
  136.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  137.     PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
  138.     PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
  139.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  140. INPUT_PORTS_END
  141.  
  142.  
  143.  
  144. static struct GfxLayout charlayout =
  145. {
  146.     8,8,        /* 8*8 characters */
  147.     512,        /* 512 characters */
  148.     2,        /* 2 bits per pixel */
  149.     { 4, 0 },    /* the bitplanes are packed in one nibble */
  150.     { 3, 2, 1, 0, 8*8+3, 8*8+2, 8*8+1, 8*8+0 },    /* x bit */
  151.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8   },     /* y bit */
  152.     16*8    /* every char takes 16 consecutive bytes */
  153. };
  154.  
  155. static struct GfxLayout spritelayout =
  156. {
  157.     16,16,        /* 16*16 sprites */
  158.     128,        /* 128 sprites */
  159.     2,        /* 2 bits per pixel */
  160.     { 4, 0 },    /* the bitplanes are packed in one nibble */
  161.     { 12*16+3,12*16+2,12*16+1,12*16+0,
  162.        8*16+3, 8*16+2, 8*16+1, 8*16+0,
  163.        4*16+3, 4*16+2, 4*16+1, 4*16+0,
  164.             3,      2,      1,      0 },            /* x bit */
  165.     {  0*8,  1*8,  2*8,  3*8,  4*8,  5*8,  6*8,  7*8,
  166.       32*8, 33*8, 34*8, 35*8, 36*8, 37*8, 38*8, 39*8  },    /* y bit */
  167.     64*8    /* every char takes 64 consecutive bytes */
  168. };
  169.  
  170. static struct GfxDecodeInfo gfxdecodeinfo[] =
  171. {
  172.     { REGION_GFX1, 0, &charlayout,         0, 64 },
  173.     { REGION_GFX2, 0, &spritelayout,    64*4, 64 },
  174.     { -1 } /* end of array */
  175. };
  176.  
  177.  
  178.  
  179. static struct SN76496interface sn76496_interface =
  180. {
  181.     1,            /* 1 chip */
  182.     { 18432000/8 },    /* 2.304 MHz */
  183.     { 100 }
  184. };
  185.  
  186.  
  187. static struct MachineDriver machine_driver_pingpong =
  188. {
  189.     /* basic machine hardware */
  190.     {
  191.         {
  192.             CPU_Z80,
  193.             18432000/6,        /* 3.072 MHz (probably) */
  194.             readmem,writemem,0,0,
  195.             pingpong_interrupt,16    /* 1 IRQ + 8 NMI */
  196.         }
  197.     },
  198.     60, DEFAULT_60HZ_VBLANK_DURATION,
  199.     1,
  200.     0,
  201.     /* video hardware */
  202.     32*8, 32*8, { 0*8, 32*8-1, 2*8, 30*8-1 },
  203.     gfxdecodeinfo,
  204.     32,64*4+64*4,
  205.     pingpong_vh_convert_color_prom,
  206.  
  207.     VIDEO_TYPE_RASTER,
  208.     0,
  209.     generic_vh_start,
  210.     generic_vh_stop,
  211.     pingpong_vh_screenrefresh,
  212.  
  213.     /* sound hardware */
  214.     0,0,0,0,
  215.     {
  216.         {
  217.             SOUND_SN76496,
  218.             &sn76496_interface
  219.         }
  220.     }
  221. };
  222.  
  223.  
  224.  
  225. /***************************************************************************
  226.  
  227.   Game driver(s)
  228.  
  229. ***************************************************************************/
  230.  
  231. ROM_START( pingpong )
  232.     ROM_REGION( 0x10000, REGION_CPU1 )    /* 64k for code */
  233.     ROM_LOAD( "pp_e04.rom",   0x0000, 0x4000, 0x18552f8f )
  234.     ROM_LOAD( "pp_e03.rom",   0x4000, 0x4000, 0xae5f01e8 )
  235.  
  236.     ROM_REGION( 0x2000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  237.     ROM_LOAD( "pp_e01.rom",   0x0000, 0x2000, 0xd1d6f090 )
  238.  
  239.     ROM_REGION( 0x2000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  240.     ROM_LOAD( "pp_e02.rom",   0x0000, 0x2000, 0x33c687e0 )
  241.  
  242.     ROM_REGION( 0x0220, REGION_PROMS )
  243.     ROM_LOAD( "pingpong.3j",  0x0000, 0x0020, 0x3e04f06e ) /* palette (this might be bad) */
  244.     ROM_LOAD( "pingpong.11j", 0x0020, 0x0100, 0x09d96b08 ) /* sprites */
  245.     ROM_LOAD( "pingpong.5h",  0x0120, 0x0100, 0x8456046a ) /* characters */
  246. ROM_END
  247.  
  248.  
  249.  
  250. GAME( 1985, pingpong, 0, pingpong, pingpong, 0, ROT0, "Konami", "Ping Pong" )
  251.